package com.sqsf.mapper;

import com.sqsf.javabean.Users;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {

    @Select("select * from users where username=#{username} and password=#{password} and status=1")
    Users selectUserByUsernameAndPassword(@Param("username") String username, @Param("password") String password);

    List<Users> selectU_R();

    int insert(Users users);

    @Insert("insert into users_role (userId,roleId) values(#{uid},#{rid})")
    int insertU_R(@Param("uid") int uid,@Param("rid") int rid);

    @Delete("delete from users where id=#{id}")
    int deleteById(int id);

    @Delete("delete from users_role where userId=#{id}")
    int deleteU_R(int id);

    Users selectById(int id);

    @Update("update users set username=#{username},email=#{email},phoneNum=#{phoneNum},password=#{password},status=#{status} where id=#{id}")
    int update(Users users);

    @Update("update users_role set roleId=#{rid} where userId=#{uid}")
    int updateU_R(@Param("uid") int uid,@Param("rid") int rid);



}
